package com.eric.service.impl;
import com.eric.domain.po.Menu;
import com.eric.mapper.MenuMapper;
import com.eric.service.TestService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.relation.RelationManager;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import static com.eric.domain.po.table.MenuTableDef.MENU;
@Service
public class TestServiceImpl   extends ServiceImpl<MenuMapper,Menu> implements TestService {
    @Resource
    private MenuMapper menuMapper;

    @Override
    public List<Menu> getMenu() {
        QueryWrapper qw=QueryWrapper.create();
//        默认是递归查询深度为3个成绩，如果要查询指定递归深度，需要添加配置
//        设置递归查询深度为10层，记住，有几层菜单参数就写多少
//
        RelationManager.setMaxDepth(2);//这个配置就只能查询一次后会被清除设置
        qw.where(MENU.PARENT_ID.eq(0));
        List<Menu> menus = menuMapper.selectListWithRelationsByQuery(qw);
        return menus;
    }
}
